package com.upf1sh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.upf1sh.bean.IniectionRobot;
import com.upf1sh.mapper.IniectionRobotMapper;
import com.upf1sh.service.IniectionRobotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author Lenovo
* @description 针对表【iniection_robot(注射机器人)】的数据库操作Service实现
* @createDate 2024-09-19 20:59:10
*/
@Service
public class IniectionRobotServiceImpl extends ServiceImpl<IniectionRobotMapper, IniectionRobot>
    implements IniectionRobotService {

    @Autowired
    private IniectionRobotMapper iniectionRobotMapper;

    @Override
    public List<IniectionRobot> getList(IniectionRobot iniectionRobot) {
        QueryWrapper<IniectionRobot> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(iniectionRobot.getPigFiel()!=null,"pig_fiel",iniectionRobot.getPigFiel());
        queryWrapper.eq(iniectionRobot.getInjectionType()!=null,"injection_type",iniectionRobot.getInjectionType());

        return iniectionRobotMapper.selectList(queryWrapper);
    }

    @Override
    public int add(IniectionRobot iniectionRobot) {
        iniectionRobot.setInjectionTime(String.valueOf(new Date().getTime()));
        return iniectionRobotMapper.insert(iniectionRobot);
    }

    @Override
    public int delete(IniectionRobot iniectionRobot) {
        return iniectionRobotMapper.deleteById(iniectionRobot.getId());
    }

    @Override
    public int update(IniectionRobot iniectionRobot) {
        return iniectionRobotMapper.updateById(iniectionRobot);
    }

    @Override
    public IniectionRobot iniectionRobot(int id) {
        return iniectionRobotMapper.selectById(id);
    }

    @Override
    public IniectionRobot getInfo(IniectionRobot iniectionRobot) {
        QueryWrapper<IniectionRobot> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(iniectionRobot.getPigFiel()!=null,"pig_fiel",iniectionRobot.getPigFiel());
        queryWrapper.eq(iniectionRobot.getInjectionType()!=null,"injection_type",iniectionRobot.getInjectionType());

        return iniectionRobotMapper.selectOne(queryWrapper);
    }
}




